extends Node2D


func _ready() -> void:
    GameService.request_destory_pickup.connect(on_destory_pickupbox)
    $CanvasLayer/InventoryComponent.event_slot_triggered.connect(on_inventory_component_event_slot_triggered)

func on_destory_pickupbox(pickup: PickableComponent) -> void:
    pickup.queue_free()

func on_inventory_component_event_slot_triggered(inventory: InventoryComponent, slot: InventorySlot) -> void:
    var c: CharacterComponent = $CanvasLayer/CharacterPlaceHolder.get_character()
    var knapsack: IInventoryComponent = c.subassembly("Knapsack")
    if knapsack:
        slot.inventory_item.amount += 1
        knapsack.pickup(slot.inventory_item)
